<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;

/**
 * @property int $id 
 * @property int $user_id 
 * @property string $name 
 * @property string $logo 
 * @property string $province 
 * @property int $province_id 
 * @property string $city 
 * @property int $city_id 
 * @property string $district 
 * @property int $district_id 
 * @property string $address 
 * @property float $longitude 
 * @property float $latitude 
 * @property string $tel 
 * @property int $status 
 * @property string $audit_result 
 * @property string $legal_name 
 * @property string $legal_idcard 
 * @property string $idcard_positive 
 * @property string $idcard_negative 
 * @property string $company_name 
 * @property string $company_license_number 
 * @property string $company_license_pic 
 * @property int $enable_full_discount 
 * @property float $full_discount_rate 
 * @property int $enable_coupon 
 * @property int $enable_voucher 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $deleted_at 
 */
class Business extends Model
{
    use SoftDeletes;

    public $dateFormat = 'U';
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'business';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = ['id'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'user_id' => 'integer', 'province_id' => 'integer', 'city_id' => 'integer', 'district_id' => 'integer', 'longitude' => 'float', 'latitude' => 'float', 'status' => 'integer', 'enable_full_discount' => 'integer', 'full_discount_rate' => 'float', 'enable_coupon' => 'integer', 'enable_voucher' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'integer'];

    /**
     * 商家LOGO修改器
     *
     * @param $value
     * @return string|string[]
     */
    public function setLogoAttribute($value)
    {
        return str_replace('ali_oss_domain', '', $value);
    }

    /**
     * 商家LOGO获取器
     *
     * @param $value
     * @return string
     */
//    public function getLogoAttribute($value)
//    {
//        return gConfig('ali_oss_domain') . $value;
//    }

    /**
     * 商家店铺环境获取器
     *
     * @param $value
     * @return string
     */
    public function getScienceAttribute($value)
    {
        return $value ? json_decode($value):[];
    }

    /**
     * 商家标签获取获取器
     *
     * @param $value
     * @return string
     */
    public function getTagAttribute($value)
    {
        return $value ? json_decode($value):[];
    }
}